package com.site.blog.my.core.service.impl;

import com.site.blog.my.core.dao.AdminUserMapper;
import com.site.blog.my.core.entity.Blog;
import com.site.blog.my.core.entity.FilePo;
import com.site.blog.my.core.util.PageQueryUtil;
import com.site.blog.my.core.util.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;

@Service
public class FileServiceImpl {

    @Resource
    private AdminUserMapper adminUserMapper;

    public void insert(FilePo filePo) {
        adminUserMapper.insertFile(filePo);
    }

    public PageResult getFilesPage(PageQueryUtil pageUtil) {

        List<FilePo> blogList = adminUserMapper.findFileList(pageUtil);
        int total = adminUserMapper.getFileTotal(pageUtil);
        PageResult pageResult = new PageResult(blogList, total, pageUtil.getLimit(), pageUtil.getPage());
        return pageResult;
    }

    public boolean download(Integer id, HttpServletResponse response) {



        return true;
    }
}
